#include "AI.h"

extern list<WordInfo> word_list;
extern list<WordInfo>::iterator word_it;

extern list<OntologyInfo> ontology_list;
extern list<OntologyInfo>::iterator ontology_it;
extern list<string>::iterator ontology_word_it;

void OntologyTag()
{
	list<WordInfo>::iterator word_it_for;

	bool flag;

	for(word_it = word_list.begin(); word_it != word_list.end(); word_it++)
	{
		for(ontology_it = ontology_list.begin(); ontology_it != ontology_list.end(); ontology_it++)
		{
			flag = false;
			word_it_for = word_it;

			for(ontology_word_it = ontology_it->ontology_word_list.begin(); ontology_word_it != ontology_it->ontology_word_list.end(); ontology_word_it++)
			{
				if(word_it_for == word_list.end())
				{
					flag = false;
					break;
				}

				else if(word_it_for->word == *ontology_word_it)
				{
					word_it_for++;
					flag = true;
				}
				
				else
				{
					flag = false;
					break;
				}
			}

			if(flag)
			{
				word_it->type = ontology_it->tag;
				break;
			}
		}
	}
}